import 'dart:convert';

import 'package:largefriends/entity/json/json_parse_utils.dart';

const int photoTypePublic = 1;
const int photoTypePrivate = 2;

class LfPhotoEntity {
  LfPhotoEntity({
    this.attachId,
    this.avatar = false,
    this.height,
    this.sort,
    this.status = 0,
    this.url,
    this.width,
    this.hasFace,
    this.type = 1,

    ///本地变量,1:public 2:private
  });

  factory LfPhotoEntity.fromJson(Map<dynamic, dynamic> jsonRes) =>
      LfPhotoEntity(
        attachId: jsonRes.asString('attachId'),
        avatar: jsonRes.asBool('avatar'),
        height: jsonRes.asString('height'),
        sort: jsonRes.asString('sort'),
        status: jsonRes.asInt('status', 0),
        url: jsonRes.asString('url'),
        width: jsonRes.asString('width'),
        hasFace: jsonRes.asString('hasFace'),
      );

  String? attachId;
  bool avatar = false;
  String? height;
  String? sort;
  int status;
  String? url;
  String? width;
  String? hasFace;
  int type = 1;

  ///本地变量,1:public 2:private

  @override
  String toString() {
    return jsonEncode(this);
  }

  Map<String, dynamic> toJson() => <String, dynamic>{
        'attachId': attachId,
        'avatar': avatar,
        'height': height,
        'sort': sort,
        'status': status,
        'url': url,
        'width': width,
        'hasFace': hasFace,
      };
}
